﻿<%@ WebHandler Language="C#" Class="HQSWcfService.Web.Template.PatientInfo" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HQSWcfService.Web.Template
{
    /// <summary>
    /// PatientList 的摘要说明
    /// </summary>
    public class PatientInfo : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string mac = context.Request["mac"].ToUpper();
            int PatientQueueId = int.Parse(context.Request["id"]);

            using (shinetriageEntities shineTriage = new shinetriageEntities())
            {
                var patientQueueData = shineTriage.patient_queue.FirstOrDefault(p => p.id == PatientQueueId);
                terminal terminalData = shineTriage.terminal.FirstOrDefault(t => t.mac == mac);
                string sjsons = JSONSerialize.Serialize(
                                                patientQueueData == null ?
                                                null :
                                                new
                                                {
                                                    terminalName = terminalData.display_name,
                                                    PagerName = patientQueueData.pager == null ? "" : patientQueueData.pager.display_name,
                                                    ClinicName = patientQueueData.pager == null ? "" : patientQueueData.pager.name,
                                                    PatientName = patientQueueData.patient_name
                                                });

                System.IO.File.AppendAllText(context.Server.MapPath("log.txt"), "sjsons:" + sjsons + "\r\n");
                context.Response.Write(sjsons);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}